package Homework01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class work08 {
    public static void main(String[] args) {

        // 准备牌
        ArrayList<Integer> poker = new ArrayList<Integer>();
        Map<Integer, String> map = new HashMap();
        // 定义两个数组
        String[] colors = { "♥", "♣","♦" ,"♠"  };
        String[] numbers = { "2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3" };
        poker.add(0);
        poker.add(1);
        // 组装52张牌
        Integer index = 2;
        map.put(0, "大王");
        map.put(1, "小王");
        for (String number : numbers) {
            for (String color : colors) {
                poker.add(index);
                map.put(index, color + number);
                index++;
            }
        }

        // 洗牌
        Collections.shuffle(poker);

        Player playe1 = new Player("老王");
        Player playe2 = new Player("老李");
        Player playe3 = new Player("老刘");
        // 摸牌
        for (int i = 0; i < poker.size(); i++) {
            // 每一张牌
            Integer p = poker.get(i);
            if (i <= 51) {
                if (i % 3 == 0) {
                    playe1.getList().add(p);
                } else if (i % 3 == 1) {
                    playe2.getList().add(p);
                } else {
                    playe3.getList().add(p);
                }
            }
        }
        Collections.sort(playe1.getList());
        Collections.sort(playe2.getList());
        Collections.sort(playe3.getList());
        // 看牌
        List<String> poker1 = playe1.getList().stream()
                .map(map::get)
                .collect(Collectors.toList());
        System.out.println(poker1);

        List<String> poker2 = playe2.getList().stream()
                .map(map::get)
                .collect(Collectors.toList());
        System.out.println(poker2);

        List<String> poker3 = playe3.getList().stream()
                .map(map::get)
                .collect(Collectors.toList());
        System.out.println(poker3);
    }
}